package jwt;


import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTCreator;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.Claim;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.auth0.jwt.interfaces.Verification;

/**
 * @Author 史祥连
 * @Date 2024/11/25 13:39
 * @Version 1.0
 */
public class JWTDemo {
    public static void main(String[] args) {
        JWTCreator.Builder builder = JWT.create();
        builder.withClaim("shxl","111");
        String test = builder.sign(Algorithm.HMAC256("test"));

        Verification verification = JWT.require(Algorithm.HMAC256("test"));
        JWTVerifier verifier = verification.build();
        DecodedJWT decodedJWT = verifier.verify(test);
        Claim shxl = decodedJWT.getClaim("shxl");

    }
}
